﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class 创建水晶柱 : MonoBehaviour
{
    public GameObject m_obj;
    public int m_nCount = 20;

    [ContextMenu("创建水晶柱")]
    private void fuck()
    {
        for (int i = 0; i < m_nCount; i++)
        {
            float x = Random.Range(-5.0f, 5.0f);
            float y = Random.Range(-5.0f, 5.0f);
            float dis = Vector3.Distance(Vector3.zero, new Vector3(x, 0, y));
            if (dis < 0.7f || dis > 5.0f)
            {
                i--;
                continue;
            }
            Instantiate(m_obj, new Vector3(x, 0, y), Quaternion.Euler(0, 0, 0), transform);
        }
    }

    [ContextMenu("清楚所有")]
    private void 清楚所有()
    {
        foreach (var item in GetComponentsInChildren<Transform>())
        {
            if (item != transform)
            {
                DestroyImmediate(item.gameObject);
            }
        }
    }
}
